package GameEngine.gui;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import javax.swing.JFrame;

import GameEngine.Pentagorun;
import GameEngine.Player;


public class Main {
	public static void main(String[] args)
	{
	//  Welcome text

        System.out.println("Welcome to PentagoPP (S.C.A.P.F)!");

        // lets get some input
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        String result_input = "no input";

        //request for the interface mode
        while (!((result_input.equalsIgnoreCase("text")) ^ (result_input.equalsIgnoreCase("gui")))) {
            System.out.println("Please choose graphical mode (gui) or text mode (text):");
            try {
                result_input = input.readLine();
            } catch (Exception ex) {
                System.out.println("Wrong input(" + ex + "), please try again!");
            }
        }
        // interface mode selected

        //If you have chosen graphical user interface, the GUI will start here
        if (result_input.equalsIgnoreCase("gui")) {

            /**
             * @param gui the video mode of Pentago will start
             * @param Video.main the Video class will be focused an starts the PApplet by calling Video in the String
             */
            //lead us the to Video class
        	Pentago mainFrame = new Pentago();
        }

        //If you have chosen text mode, the console game will start here by asking you witch game play mode you want to play
        if (result_input.equalsIgnoreCase("text")) {

            //represents the game mode as an int
            int mode = 0;

            // the request of the game play mode
            while (!(mode >= 1 && mode <= 5)) {
                System.out.println("\nPlease choose game mode:\n\n\t* Player vs. Player (1)\n\t* Player vs. AI (2)" +
                        "\n\t* AI vs. AI (3)\n\t* Netplayer as host (4)\n\t* Netplayer as client (5)\n");
                try {
                    mode = Integer.parseInt(input.readLine()); // parse int of the input
                } catch (Exception ex) {
                    System.out.println("Wrong input(" + ex + "), please try again.");
                }
            }
            
            Pentagorun textPentago = new Pentagorun();
            textPentago.startGame(mode);
		
		}
}
	}
